import request from '@/utils/request'
import {reqAddRoleData, RequestData, RoleData, RoleListData} from "@/api/role/type.ts";
import {ResponseData} from "@/api/types/type.ts";

export const getRoleList = (data: RequestData): Promise<RoleListData> => {
    return request({
        url: '/role/getRoleList',
        data,
        method: 'POST'
    })
}
export const getRoleByID = (id: number): Promise<RoleData> => {
    return request({
        url: '/role/getRoleByID?id=' + id,
        method: 'get'
    })
}

export const updateRole = (data: any): Promise<ResponseData> => {
    return request({
        url: '/role/updateRole',
        method: 'post',
        data
    })
}

export const deleteRole = (id: any): Promise<ResponseData> => {
    return request({
        url: '/role/deleteRole?id=' + id,
        method: 'DELETE'
    })
}

export const deleteRoles = (ids: number[]): Promise<ResponseData> => {
    return request({
        url: '/role/deleteRoles',
        method: 'DELETE',
        data: {"ids": ids}
    })
}
export const createRole = (data: reqAddRoleData): Promise<ResponseData> => {
    return request({
        url: '/role/createRole',
        method: 'POST',
        data
    })
}